<template>
  <div class="app-container">
    <Top></Top>
    
    <div class="content-wrapper">
      <!-- 左侧导航 -->
      <aside class="sidebar">
        <div class="category-item domestic" @click="activeCategory = 'domestic'">国内新闻</div>
        <div class="category-item entertainment" @click="activeCategory = 'entertainment'">娱乐新闻</div>
        <div class="category-item sport" @click="activeCategory = 'sport'">体育新闻</div>
      </aside>
      
      <!-- 右侧内容区 -->
      <main class="content-area">
        <Homes v-if="activeCategory === 'domestic' || activeCategory === ''"></Homes>
        <Entertainment v-if="activeCategory === 'entertainment'"></Entertainment>
        <Sport v-if="activeCategory === 'sport'"></Sport>
      </main>
    </div>
    
    <Bottom1></Bottom1>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
// 保持原有的导入方式不变
import Top from '../components/Top.vue';
import Homes from '../components/Homes.vue';
import Entertainment from '../components/Entertainment.vue';
import Sport from '../components/Sport.vue';
import Bottom1 from '../components/Bottom1.vue';

// 用于控制显示哪个分类的新闻
const activeCategory = ref('');
</script>

<style scoped>
.app-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  font-family: "Microsoft YaHei", sans-serif;
  box-sizing: border-box;
}

.content-wrapper {
  display: flex;
  margin: 20px 0;
  gap: 20px;
  min-height: 500px;
}

.sidebar {
  width: 160px;
  flex-shrink: 0;
}

.category-item {
  width: 100%;
  height: 80px;
  margin-bottom: 15px;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.category-item:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.category-item.active {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.domestic {
  background-color: #2c3e50;
}

.entertainment {
  background-color: #e74c3c;
}

.sport {
  background-color: #27ae60;
}

.content-area {
  flex: 1;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

@media (max-width: 768px) {
  .content-wrapper {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    display: flex;
    gap: 10px;
  }
  
  .category-item {
    flex: 1;
    margin-bottom: 0;
  }
}
</style>
    